import pymysql
from shuogg import random_util

HOST = '127.0.0.1'
USER = 'root'
PASSWORD = 'ut123456'
PORT = 3306

# 百万条记录插入

conn = pymysql.connect(host=HOST, user=USER, passwd=PASSWORD,
                       port=PORT, db='shuogg', charset='utf8')
cur = conn.cursor()
try:
    for i in range(0, 1000000):
        cur.execute('insert into user(name, age) values("%s", %d)' % (random_util.uuid1(), random_util.num(2)))
    conn.commit()
except:
    conn.rollback()
cur.close()
conn.close()
